1. Field of the Invention
The present invention relates to the design of platform-independent virtual machines. More specifically, the present invention relates to a method and an apparatus to facilitate code verification and garbage collection in a platform-independent virtual machine.
2. Related Art
Dramatic advances in computer technology presently make it possible to integrate a significant amount of computing power onto “smart cards.” Smart cards are presently used in a variety of applications that solve common security and identity needs. For example, smart cards have been integrated into credit cards, debit cards, corporate badges, and even cell phones.
New smart card designs can accommodate larger amounts of memory. For example, new smart card designs can accommodate up to 160K bytes of read-only memory (ROM), 64 K bytes of electrically erasable programmable read-only memory (EEPROM), and 8 K bytes of random access memory (RAM). These larger amounts of memory make it possible to integrate more functionality into a smart card.
In particular, the additional memory can be used to implement a virtual machine, such as the JAVA™ virtual machine (JVM), in a smart card, and to allow the use of objects defined within an object-oriented programming system. (JAVA is a trademark of SUN Microsystems, Inc. of Santa Clara, Calif.) Integrating a virtual machine into a smart card enables the smart card to execute a large number of platform-independent applications. Moreover, the associated development environment for the virtual machine can simplify the process of developing applications for smart cards.
While it is possible to implement a virtual machine on one of these smart cards, the memory is still quite limited compared to a typical desktop computer system. This limited memory leads to many challenges in the implementing a virtual machine.
One problem is that programming languages, such as JAVA and corresponding JAVA bytecodes, are often unnecessarily complicated, which leads to unnecessary complexity in the virtual machine. In particular, the JAVA programming language (and corresponding JAVA bytecodes) can leave data on the stack during a call to a method. This data can cause difficulties during code verification and garbage collection because this data is left between activation records where it complicates the garbage collection and verification processes. For example, in the Connected Limited Device Configuration (CLDC) version of Java, bytecodes include a typemap for each basic block within the method. A typemap provides a map of local variable and stack types in a method. Having multiple typemaps per method unnecessarily complicates garbage collection because the garbage collector needs to access each of these typemaps during garbage collection. Additionally, variables can hold different types of data at different times. A variable in one instance can be a pointer and the same variable at another time can be a primitive data type, such as an integer or float. This causes difficulties for the garbage collector and verifier because they have to determine the type of a variable before completing their functions.
Hence, what is needed is a method and an apparatus that facilitates code verification and garbage collection in a platform-independent virtual machine without the problems described above.